<script setup>
import { computed } from 'vue'
import { useAppStore } from '@/store/modules/app'
import { AppMain, NavigationBar, Sidebar } from './components'

const appStore = useAppStore()

const layoutClasses = computed(() => {
  return {
    'hide-sidebar': !appStore.sidebar.opened,
    'open-sidebar': appStore.sidebar.opened,
    'without-animation': appStore.sidebar.withoutAnimation,
  }
})
</script>

<template>
  <div :class="layoutClasses" class="app-wrapper">
    <div class="main-container">
      <div class="layout-header">
        <NavigationBar />
      </div>
      <AppMain class="app-main" />
    </div>
  </div>
</template>

<style lang="scss" scoped>
@use '@/styles/mixins' as *;

$transition-time: 0.35s;

.app-wrapper {
  @extend %clearfix;

  position: relative;
  max-width: 1200px;
  margin: 0 auto;
  background: var(--el-bg-color-page);
  box-shadow: 0 0 15px rgba(#000, 0.08);
}

.drawer-bg {
  position: absolute;
  top: 0;
  z-index: 999;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.3);
}

.sidebar-container {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 1001;
  width: 220px !important;
  height: 100%;
  overflow: hidden;
  background-color: var(--el-color-white);
  border-right: 1px;
  box-shadow: 0 -4px 16px 0 #3333331f;
  transition: width $transition-time;
}

.main-container {
  position: relative;
  min-height: 100%;
}

.fixed-header {
  position: fixed !important;
  top: 0;
  right: 0;
  z-index: 9;
  width: 100%;
  transition: width $transition-time;
}

.layout-header {
  position: relative;
  z-index: 9;
  background-color: var(--el-bg-color-page);
  box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
}

.app-main {
  position: relative;
  min-height: calc(100vh - 60px);
  overflow: hidden;
  background-color: #fcfcfc;
}

.hide-sidebar {
  .sidebar-container {
    width: 60px !important;
  }

  .main-container {
    margin-left: 60px;
  }

  .fixed-header {
    width: calc(100% - 60px);
  }
}

.without-animation {
  .sidebar-container,
  .main-container {
    transition: none;
  }
}
</style>
